﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{


    public partial class UIABAX : ViewBase
    {
        #region ==dwMU===========
        public static readonly DependencyProperty dwMUProperty = DependencyProperty.Register("dwMU",
            typeof(DataRow), typeof(UIABAX),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwMUChanged));
        public DataRow dwMU
        {
            get
            {
                return (DataRow)GetValue(dwMUProperty);
            }
            set
            {
                SetValue(dwMUProperty, value);
            }
        }
        private static void OdwMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAX;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwMU = row;
            }
        }
        #endregion

        #region ==FTMULOAD===========
        public static readonly DependencyProperty FTMULOADProperty = DependencyProperty.Register("FTMULOAD",
            typeof(bool), typeof(UIABAX),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTMULOADChanged));
        public bool FTMULOAD
        {
            get
            {
                return (bool)GetValue(FTMULOADProperty);
            }
            set
            {
                SetValue(FTMULOADProperty, value);
            }
        }
        private static void OnFTMULOADChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAX;
            if (src != null)
            {
                src.FTMULOAD = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==ABAUF===========
        public static readonly DependencyProperty ABAUFProperty = DependencyProperty.Register("ABAUF",
            typeof(string), typeof(UIABAX),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABAUFChanged));
        public string ABAUF
        {
            get
            {
                return (string)GetValue(ABAUFProperty);
            }
            set
            {
                SetValue(ABAUFProperty, value);
            }
        }
        private static void OnABAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABAX;
            if (src != null)
            {
                src.ABAUF = (string)e.NewValue;
            }
        }
        #endregion

        public UIABAX()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
          
         }


        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
        }

        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwMU = dwMaster;
            if (dwMU == null)
            {
                ABAUF = "";
            }
            else
            {
                ABAUF = dwMU["ABAAUFKRS"].ToString() + dwMU["ABAAUFLFD"].ToString() + dwMU["ABAAUFPOS"].ToString();
            }
        }
         
    }
}
